import TJavaLib.TList;

public class TNetwork {
	private TList net;
	private TNetworkView netView;
	private TControlView ctrlView;
	private double depW, depH;
	
	public TNetwork() {
		net = new TList();
		depW = 1000;
		depH = 1000;
	}

	public int len() { 
		return net.len(); 
	}
	
	public TList getNetwork() { 
		return net; 
	}

	public TNetworkView getNetView() {
		return netView;
	}
	
	public TControlView getCtrlView() {
		return ctrlView;
	}
	
	public TNetworkView newView(String title) { 
		netView = new TNetworkView(this, title); 
		return netView;
	}
	
	public TControlView newCtrlView(String title) { 
		ctrlView = new TControlView(this, title); 
		return ctrlView;
	}
	
	public TSensor newSensor() {
		TSensor sensor = new TSensor();
		net.enList(sensor);
		return sensor;
	}
	
	public TGateway newGateway() {
		TGateway gateway = new TGateway();
		net.enList(gateway);
		return gateway;
	}
	
	public void reset() { 
		net.clear();
	}	
	
	public void destroy() {
		net = null;
		netView.getFrame().dispose();
		if (ctrlView != null)
			ctrlView.getFrame().dispose();
	}
	
	public void setDepW(double depW) { 
		this.depW = depW; 
	}
	
	public double getDepW() { 
		return depW; 
	}
	
	public void setDepH(double depH) { 
		this.depH = depH; 
	}
	
	public double getDepH() { 
		return depH; 
	}
	
	public void delNode(TNode node) {
		net.remove(node);
	}
}
